package cn.com.dcsgo.design.pattern.singleton;

import java.io.Serializable;

/**
 * 单例模式-双重检查实现懒加载-线程安全
 *
 * @author Dcsgo
 * @since 2025/9/22 8:53
 */

public class LazySingleton4 implements Serializable {
    private static volatile LazySingleton4 INSTANCE;

    /**
     * 私有化构造方法，不允许外部new实例化对象
     */
    private LazySingleton4() {

    }

    public static LazySingleton4 getInstance() {
        if (INSTANCE == null) {
            synchronized (LazySingleton4.class) {
                if (INSTANCE == null) {
                    INSTANCE = new LazySingleton4();
                }
            }
        }
        return INSTANCE;
    }
}
